package com.parkinglot.management.util;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

@Component
@Slf4j
public class SaveImg {

    public String saveUploadedImg(MultipartFile file,String timestamp) {

        StringBuilder spliceImgPath = new StringBuilder();
        spliceImgPath.append("D:\\img\\").append(timestamp).append(".jpg");
        try {
            file.transferTo(new File(spliceImgPath.toString()));
        } catch (IOException e) {
            log.error("图片保存失败:", e.getMessage());
        }
        return spliceImgPath.toString();
    }

}
